package com.bw.module_store.view

import android.graphics.Color
import android.view.View
import androidx.activity.viewModels
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bumptech.glide.Glide
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmActivity
import com.bw.module_store.R
import com.bw.module_store.databinding.ActivityStoreDetailBinding
import com.bw.module_store.viewmodel.StoreViewModel
/**
 * 智慧园区-01-商家推荐-v1.1-吴熙-20250511
 */
@Route(path = RouterPath.PATH_STORE_DETAIL_ACTIVITY)
class StoreDetailActivity : BaseMvvmActivity<ActivityStoreDetailBinding>() {
    @JvmField
    @Autowired
    var storeId=0

    private val viewModel : StoreViewModel by viewModels()


    override fun initView() {
        ARouter.getInstance().inject(this)
        viewModel.getStoreDetail(storeId)

        //头布局
        mDataBinding.title.text="企业详情"
        mDataBinding.topbarStoreDetail.setBackgroundColor(Color.WHITE)
        mDataBinding.title.setTextColor(Color.BLACK)
        mDataBinding.goBack.visibility=View.GONE
        mDataBinding.goAdd.visibility=View.GONE
        mDataBinding.goBackGray.visibility=View.VISIBLE
        mDataBinding.goBackGray.setOnClickListener { finish() }
    }

    override fun observeDataChange(){
        viewModel.getStoreDetailSuccess.observe(this){
            mDataBinding.tvStoreName.text=it.name
            mDataBinding.tvStoreType.text=it.industryType
            mDataBinding.tvStoreAddress.text=it.address
            mDataBinding.tvStorePerson.text=it.legalRepresentative
            mDataBinding.tvStoreTel.text=it.contactInfo
            mDataBinding.tvStoreStatus.text=it.status
            mDataBinding.tvStoreIsOn.text=if (it.listed)"已上市" else "未上市"
            mDataBinding.tvStoreStockName.text=it.stockName
            mDataBinding.tvStoreStockCode.text=it.stockCode
            Glide.with(this).load(it.photos[0]).transform(RoundedCorners(10)).into(mDataBinding.ivStorePic)
        }
    }

    override fun getLayoutId(): Int = R.layout.activity_store_detail
}